package pl.jtb.ctl.tabory.ui.security;

import pl.jtb.ctl.tabory.dao.data.sl.UserRoleSL;
import pl.jtb.ctl.tabory.dao.data.vo.UserVO;

public class CredentialsValidaton {

    private static CredentialsValidaton instance;

    private CredentialsValidaton() {
    }

    public static CredentialsValidaton getInstance() {
        if (instance == null) {
            instance = new CredentialsValidaton();
        }
        return instance;
    }

    public boolean isValidFor(UserRoleSL role) {
        boolean result = false;
        UserVO user = CredentialProvider.getInstance().getUser();
        if (user == null) {
            return false;
        }
        if (user.getUserRoleVO() == null) {
            return false;
        }
        if (user.getUserRoleVO().getId().equals(role.getId())) {
            result = true;
        }
        return result;
    }

}
